﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Search.aspx.cs" Inherits="RecipeBookWeb.Search" Title="Search Recipes" %>

<asp:Content ID="RecipeViewContent" ContentPlaceHolderID="MainContent" Runat="Server">
    <div class="post">
        <h2 class="title">Search for a Recipe</h2>
	    <div class="entry">
            <asp:TextBox runat="server" ID="SearchTextBox" Width="200" />&nbsp;
            <asp:DropDownList runat="server" ID="SearchTypeDropDownList" />&nbsp;
            <asp:Button runat="server" ID="SearchButton" Width="75" Text="Search" CausesValidation="false" OnClick="SearchButton_Click" />
		</div>
		<asp:Label ID="NoResultsLabel" runat="server" Text="No Search Results Found" Visible="false" ForeColor="Red" Font-Bold="true" Font-Size="Large"></asp:Label>
		<asp:GridView ID="SearchResultsGridView" runat="server" AutoGenerateColumns="false" Width="98%" GridLines="Horizontal">
		    <Columns>
		        <asp:TemplateField HeaderText="Recipe Name" ItemStyle-Width="40%">
		            <ItemTemplate>
		                <asp:HyperLink runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>' NavigateUrl='<%# "ViewRecipe.aspx?RecipeID=" + DataBinder.Eval(Container.DataItem, "ID").ToString() %>' />
		            </ItemTemplate>
		        </asp:TemplateField>
		        <asp:TemplateField HeaderText="Date Added" ItemStyle-Width="15%">
		            <ItemTemplate>
		                <%# ((DateTime)DataBinder.Eval(Container.DataItem, "DateAdded")).ToShortDateString() %>
		            </ItemTemplate>
		        </asp:TemplateField>
		        <asp:BoundField DataField="Username" HeaderText="Created By" ItemStyle-Width="15%" />
		        <asp:TemplateField HeaderText="Rating" ItemStyle-Width="10%">
		            <ItemTemplate>
		                <%# DataBinder.Eval(Container.DataItem, "CompositeRating").ToString() %> / 7
		            </ItemTemplate>
		        </asp:TemplateField>
		        <asp:TemplateField HeaderText="Categories" ItemStyle-Width="20%">
		            <ItemTemplate>
		                <%# DataBinder.Eval(Container.DataItem, "CategoryList").ToString().Replace("^", "<br>") %>
		            </ItemTemplate>
		        </asp:TemplateField>
		    </Columns>
		</asp:GridView>
	</div>
</asp:Content>
